package com.learnyou.server.xingzuo.controller.web.impl;

import com.learnyou.server.xingzuo.biz.IDeviceBiz;
import com.learnyou.server.xingzuo.common.exception.ApiResult;
import com.learnyou.server.xingzuo.controller.web.DeviceResource;
import com.learnyou.server.xingzuo.dto.paramDTO.pet.DeviceBaseInfoDTO;
import com.learnyou.server.xingzuo.dto.paramDTO.pet.DevicePingParamDTO;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class DeviceController implements DeviceResource {

    @Resource
    private IDeviceBiz deviceBiz;

    @Override
    public ApiResult ping(DevicePingParamDTO devicePingParamDTO) {
        deviceBiz.ping(devicePingParamDTO);
        return ApiResult.success();
    }

    @Override
    public ApiResult registerAccount(String deviceNo, String phone) {
        deviceBiz.registerAccount(deviceNo, phone);
        return ApiResult.success();
    }

    @Override
    public ApiResult unbindAccount(String deviceNo, String phone) {
        deviceBiz.unbindAccount(deviceNo, phone);
        return ApiResult.success();
    }

    @Override
    public List<String> getDevicesByAccount(String phone) {
        return deviceBiz.getDevicesByAccount(phone);
    }

    @Override
    public DeviceBaseInfoDTO getBaseInfo(String deviceNo) {
        return deviceBiz.getBaseInfo(deviceNo);
    }

    @Override
    public ApiResult updateBaseInfo(DeviceBaseInfoDTO deviceBaseInfoDTO, Integer id) {
        deviceBiz.updateBaseInfo(deviceBaseInfoDTO, id);
        return ApiResult.success();
    }
}
